package com.lecture.java8.io;

import java.io.FileOutputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.util.HashMap;

/**
 * @author luyn
 * @version 1.0
 * @description 对象流的使用
 * @date 2021/1/19 9:09
 */
public class ObjectInputStreamTest {
    public static void main(String[] args) throws Exception {
        /*ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream("E:\\ZN\\object.data"));
        os.writeObject(new String("我爱北京天安门"));
        os.flush();
        os.close();
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("E:\\\\ZN\\\\object.data"));
        Object o = ois.readObject();
        String str = (String)o;
        System.out.println(str);
        ois.close();*/
        HashMap<String, String> map = new HashMap<>();
        map.size();
        map.put("","");
        Person person = new Person();
        person.setAge(12);
        person.setName("张三");

        ObjectOutput oos = new ObjectOutputStream(new FileOutputStream("E:\\ZN\\person.data"));

        oos.writeObject(person);

        oos.close();


    }
}
